﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace com.orange.examination
{
    public partial class WebForm13 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["admin"] == null)
            {
                Response.Redirect("../LoginAndRegister/Login.aspx");
            }else
            if (!IsPostBack)
            {
                string strsql = "select * from tb_test order by ID desc";
                BaseClass.BindDG(gvExaminationInfo, "ID", strsql, "ExaminationInfo");

                string sql = "select LessonName  from tb_Lesson";
                DataSet ds = BaseClass.ExecDataSet(sql);
                ddlEkm.DataSource = ds.Tables[0];
                ddlEkm.DataTextField = "LessonName";
                ddlEkm.DataBind();
            }
        }
        public string Getstatus(string zt)
        {
            if (zt == "0")
                return "否";
            else
                return "是";
        }
        protected void btnSerch_Click(object sender, EventArgs e)
        {
            string strsql = "select * from tb_test where testCourse='" + ddlEkm.SelectedItem.Text + "'";
            BaseClass.BindDG(gvExaminationInfo, "ID", strsql, "Result");
            lbltype.Text = ddlEkm.SelectedItem.Text;
        }
        protected void gvExaminationInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int id = (int)gvExaminationInfo.DataKeys[e.RowIndex].Value;
            string sql = "delete from tb_test where ID=" + id;
            BaseClass.OperateData(sql);
            string strsql = "select * from tb_test order by ID desc";
            BaseClass.BindDG(gvExaminationInfo, "ID", strsql, "ExaminationInfo");
        }

        protected void gvExaminationInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvExaminationInfo.PageIndex = e.NewPageIndex;
            string strsql = "select * from tb_test order by ID desc";
            BaseClass.BindDG(gvExaminationInfo, "ID", strsql, "ExaminationInfo");
        }
    }
}